home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4824 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: ts169.eiu.bgu.edu!MJ-PHeee
  2. From: MJ-PHeee@bgu.edu (Martin Phee)
  3. Newsgroups: comp.lang.c
  4. Subject: Memory available during execution...
  5. Date: Wed, 7 Feb 1996 01:32:17 +1000
  6. Organization: Educational Computing Network
  7. Message-ID: <MJ-PHeee.1.01147BBA@bgu.edu>
  8. NNTP-Posting-Host: ts169.eiu.bgu.edu
  9. Keywords: memory, coreleft...
  10. X-Newsreader: Trumpet for Windows [Version 1.0 Rev B]
  11.  
  12. In borland we used farcoreleft to retrieve how much memory we had during 
  13. program execution.  We recently moved our program to MSVC, and need a way to 
  14. calculated how much avaiable memory there is during program execution.  This 
  15. is a dos program...
  16.  
  17. I have been using the little function to calculate the memory..
  18.  
  19. long get_farheap()
  20. {
  21.     unsigned long size = 0L;
  22.     int heapstatus;                                    
  23.     _HEAPINFO hinfo;
  24.  
  25.     hinfo._pentry = NULL;
  26.     while((heapstatus = _fheapwalk( &hinfo)) != _HEAPEND)
  27.     {
  28.         if(hinfo._useflag == _FREEENTRY)
  29.             size += (long)hinfo._size;        
  30.     }
  31.     return(size);
  32. }
  33.  
  34. I doesn't seen to give accurate sizes back.  It can range anywhere from 11k to 
  35. 90k.  When I know that it should be much higher...
  36.  
  37. marty
  38.